import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vant from 'vant'
import 'vant/lib/index.css'

Vue.use(Vant)

Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
    if (localStorage.getItem("Flag")) {
        let getFlag = localStorage.getItem("Flag");
        if (getFlag === "isLogin") {
            //设置vuex登录状态为已登录
            store.state.isLogin = true
            next()
        }
    } else {
        if (to.path === '/login') {
            next();
        } else {
            next('/login');
        }
    }
})

router.afterEach(() => {
    window.scroll(0, 0);
});

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
